//////////////////////////////////////////////////////
// DirectSound.h
//////////////////////////////////////////////////////

#pragma once

#include "dsound.h"
#include <stdio.h>
#include <D3dx8tex.h>
#include "Constants.h"

class CDirectSound
{
protected:
    IDirectSound8* g_pDSObject;
	DSBUFFERDESC dsbd; //buffer description
    HWND g_hWnd;
    char m_szErrorMsg[256];
	int CurrentlyPlayingMusic;	//Variable that holds enum to currently Playing Music
	IDirectSoundBuffer8* m_pTrainingGroundsMusic;
	IDirectSoundBuffer8* m_pMonsterDieSound;
    IDirectSoundBuffer8* m_pMonsterHitSound;
    IDirectSoundBuffer8* m_pPlayerHitSound;
    IDirectSoundBuffer8* m_pItemOpenSound;
	IDirectSoundBuffer8* m_pBattleMapMusic;
	IDirectSoundBuffer8* m_pTitleScreenMusic;
	 
public:
    CDirectSound(void);
    ~CDirectSound(void);
    void SetWindowHandle(HWND hWnd);
	HRESULT InitDirectSound(void);
    char* GetErrorString(void);
    HRESULT PlaySound(int iSoundID);
	HRESULT PlayMusic(int iSoundID);
	int GetCurrentlyPlaying(void);				//So you can know what music is playing
	void SetCurrentlyPlaying(int NowPlaying);	//Set what is currently Playing
	void StopSound(int);
	void StopMusic(int);
	void Handlekeys(WPARAM);

private:
	HRESULT CreateSoundEffectBuffers();
	HRESULT CreateMusicBuffer(int iSoundID);
	IDirectSoundBuffer8 *CreateBufferFromWAV(FILE *fp, sWaveHeader *Hdr);
	BOOL LoadSoundData(IDirectSoundBuffer8 *pDSBuffer, long LockPos, FILE *fp, long Size);
	IDirectSoundBuffer8 *LoadWAV(char *Filename);
	void CleanUp(IDirectSoundBuffer8* ReleaseMe);
	
	
};